<%@ page language="java" pageEncoding="utf8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/themes/base/jquery.ui.all.css'/>" type="text/css" />
	</head>
	<body style="">
		<div id="headBar" class="head_content"></div>
		<div id="main" class="main_content">
			<form action="mt_activity_rule_save.html" onsubmit="return checkLevel();" method="post" id="mt_activity_rule_form">
				<input type="hidden" name="marketPromotion.pmtId" value="${marketPromotion.pmtId}">
					<input type="hidden" name="marketPromotion.relatedId" value="${marketPromotion.relatedId}" />
					<input type="hidden" name="marketPromotion.relatedType" value="activity" />
					<input type="hidden" name="marketPromotion.pmtsId" value="${marketPromotionScheme.pmtsId }" />
					<input type="hidden" name="ruleChanged" value="${ruleChanged}" />
					<div class="tableform">
						<h4>
							优惠方式
						</h4>
						<div class="division">
							<table>
								<tbody>
									<tr>
										<th>
											订单优惠条件：
										</th>
										<td>
											<input type="text" size="10" value="${marketPromotion.orderMoneyFrom}" name="marketPromotion.orderMoneyFrom" class="x-input ">
												<b>≤</b>订单金额 ＜ <c:if test="${not empty marketPromotion.orderMoneyTo}">
													<input type="text" name="marketPromotion.orderMoneyTo" value="${marketPromotion.orderMoneyTo}" size="10" class="x-input ">
												</c:if>
												<c:if test="${empty marketPromotion.orderMoneyTo}">
													<input type="text" name="marketPromotion.orderMoneyTo" value="999999" size="10" class="x-input ">
												</c:if>
										</td>
									</tr>
									<tr>
										<th>
											允许参加会员等级：
										</th>
										<td id="promotion_level">
											<c:forEach var="level" items="${marketPromotionMemberLevels}" varStatus="index">
												<input type="hidden" name="marketPromotionMemberLevels[${index.index }].pmlId" value="${level.pmlId}" />
												<input type="checkbox" value="${level.memberLvId}" vname="promotion_level" <c:if test="${not empty level.pmlId }">checked="checked"</c:if>
													name="marketPromotionMemberLevels[${index.index }].memberLvId" />
										 ${level.levelName}
										</c:forEach>

										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="tableform">
						<h4>
							其他设置
						</h4>
						<div class="division">
							<table width="100%" cellspacing="0" cellpadding="0" border="0">
								<tbody>
									<tr>
										<th>
											活动期间是否允许使用优惠券:
										</th>
										<td>
											<select id="marketPromotion_pmtIfcoupon" name="marketPromotion.pmtIfcoupon" style="width: 60px;">
												<option value="true">
													是
												</option>
												<option value="false">
													否
												</option>
											</select>
										</td>
									</tr>
									<tr>
										<th>
											活动规则开始时间:
										</th>
										<td>

											<input size="10" id="rule_start_time" name="marketPromotion.pmtTimeBeginString" value="${marketPromotion.pmtTimeBeginString}" class="cal cal" type="text">
										</td>
									</tr>
									<tr>
										<th>
											活动规则结束时间:
										</th>
										<td>

											<input size="10" id="rule_end_time" name="marketPromotion.pmtTimeEndString" value="${marketPromotion.pmtTimeEndString}" class="cal cal" type="text">
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="tableform">
						<h4>
							优惠内容
						</h4>
						<input type="hidden" name="marketPromotion.pmtBasicType" value="order" />
						<input type="hidden" name="marketPromotion.pmtMethod" value="exempt_freight" />
						<input type="hidden" name="marketPromotion.pmtBondType" value="2" />

						<div style="float: left;" class="division">

							<h5>
								运费
							</h5>
							是否免运费:
							<input type="checkbox" <c:if test="${marketPromotion.pmtMethodValue eq 'true'}"> checked="checked"</c:if> value="true" name="marketPromotion.pmtMethodValue" />

						</div>
						<hr class="clear" />
					</div>
					<div class="tableform">
						<h4>
							规则描述
						</h4>
						<textarea required="true" rows="6" cols="60" name="marketPromotion.pmtDescribe">${marketPromotion.pmtDescribe }</textarea>
						<br>
							<span class="fontcolorGray">此描述会显示在前台相关页面展示给顾客 </span>
					</div>
					<div class="table-action">
						<button onclick="location.href='mt_activity_rule_begin.html?marketPromotionActivity.pmtaId=${marketPromotionActivity.pmtaId}&pmtId=${marketPromotion.pmtId}&pmtsId=${oldPtmsId}'" class="btn"
							type="button">
							<span><span>上一步</span> </span>
						</button>
						<button class="btn" id="x-tonext-btn" type="submit">
							<span><span>下一步</span> </span>
						</button>
						<button class="btn" type="button">
							<span><span>取消</span> </span>
						</button>
					</div>
			</form>
		</div>
		<div id="footBar" class="foot_content"></div>

		<script type="text/javascript" src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.validate.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.core.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.widget.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.datepicker.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/i18n/jquery.ui.datepicker-zh-CN.js'/>"></script>
		<script type="text/javascript">
		
		<c:if test="${not empty marketPromotion.pmtId}">
			$('#marketPromotion_pmtIfcoupon').attr('value','${marketPromotion.pmtIfcoupon}');		
		</c:if>
		
		
	
		
		
	$(document).ready(function() {
		var validator = $("#mt_activity_rule_form").validate( {
			errorElement : "div",
			errorClass : "x-vali-error",
			onfocusout : false,
			rules : {
 				'marketPromotion.orderMoneyFrom' : {
					required : true,
					number : true
				},
				'marketPromotion.orderMoneyTo' : {
					required : true,
					number : true
				},
				'marketPromotion.pmtTimeBeginString' : "required",
				'marketPromotion.pmtTimeEndString' : "required",
				 
				'marketPromotion.pmtDescribe' : "required" 
			},
			messages : {
			
			
				'marketPromotion.orderMoneyFrom' : {
					required : "必填字段",
					number : "请输入数字"
				},
				'marketPromotion.orderMoneyTo' : {
					required : "必填字段",
					number : "请输入数字"
				},
				'marketPromotion.pmtTimeBeginString' : "必填字段",
				'marketPromotion.pmtTimeEndString' : "必填字段",
				 
				'marketPromotion.pmtDescribe' : "必填字段"
				 
			},
			errorPlacement : function(error, element) {
				element.removeClass('x-vali-error');
				error.appendTo(element.parent());

			},
			 
			success : function(div) { 
				$(div).remove();
			}
		});
	});
	
	
	function checkLevel(){
		var selected = false;
		$('#promotion_level input[vname]').each(function(i, dom) {
			if ($(dom).attr("checked")) {
				selected = true;
			}
		});
		if(!selected){
			alert('请至少选择一个等级');
		}
		return selected;
	}
	
	$("#rule_start_time").datepicker( $.datepicker.regional['zh-CN']);
	$("#rule_end_time").datepicker( $.datepicker.regional['zh-CN']);
</script>
	</body>
</html>